TOPDIR := $(abspath ..)
LOCAL_PATH := $(abspath .)
#CFLAGS += -DLINUX -D_GNU_SOURCE 
include $(TOPDIR)/build/build_config.mak

SOURCE_DIR_PREFIX := ./src

SOURCE_DIRS := $(SOURCE_DIR_PREFIX)/ \
			   $(SOURCE_DIR_PREFIX)/portable/std \
			   $(SOURCE_DIR_PREFIX)/portable/posix \
			   $(SOURCE_DIR_PREFIX)/portable/linux \
			   $(SOURCE_DIR_PREFIX)/portable/win32 \
			   $(SOURCE_DIR_PREFIX)/portable/android
			   
BUILD_SRCS := $(foreach dir, $(SOURCE_DIRS), echo $(dir) $(patsubst ./%,%, $(shell find $(dir) -maxdepth 1 -name '*.c' -o -name '*.cpp')))
#BUILD_SRCS := $(patsubst ./%,%, $(shell find . -maxdepth 1 -name '*.c'))
#BUILD_SRCS += $(patsubst ./%,%, $(shell find . -maxdepth 1 -name '*.cpp'))

INCLUDE_DIRS := $(LOCAL_PATH)/include \
				$(LOCAL_PATH)/src \
				$(LOCAL_PATH)/src/portable \
				$(TOPDIR)/general_inc

LOCAL_COMMON_FLAGS := -D_GNU_SOURCE 
LOCAL_SRCS := $(BUILD_SRCS)
LOCAL_C_INCLUDES := $(INCLUDE_DIRS)
LOCAL_MODULE := libvos

include $(BUILD_STATIC_LIBRARY)

################################################################
#build shared library
################################################################
include $(CLEAR_VARS)

LOCAL_SRCS := $(BUILD_SRCS)
LOCAL_C_INCLUDES := $(INCLUDE_DIRS)
LOCAL_COMMON_FLAGS := -D_GNU_SOURCE
LOCAL_LDFLAGS := -lm -ldl -pthread
LOCAL_MODULE := libvos
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_SUB_DIRS := $(LOCAL_PATH)/test

include $(BUILD_SUB_DIRS)
